Release 10.1A: OpenEdge Development:
ProDataSets
Doing a partial ProDataSet FILL to return Order headers
This code example continues over the following sections, each of which illustrates and explains parts of the overall procedure. When the user enters values for one or more of the filtering fields, the window procedure will format that into a
where-clauseand pass that to a new internal procedure calledfetchOrdersthat returns the ProDataSet. Add this code forfetchOrderstoOrderSupport.p:
This saves off the selection criteria and empties the server-side ProDataSet in preparation for responding to the request.
When the user requests a set of
Orders, you don’t want to return all theOrderLinedetail yet because that can be a lot of data. Instead, you just return theOrderheaders and wait for the user to select a specificOrderto fill in. For this reasonfetchOrdersneeds to set theFILL-MODEattribute for thettOlineandttItemtables to “NO-FILL.” In this way, when you then do aFILLon the ProDataSet, it fills only thettOrdertable and skips the other two tables.There are three ways to change the extent of a
FILL, either to limit or to extend the amount of data loaded into the ProDataSet at one time:
- Setting the
FILL-MODEof one or more tables to“NO-FILL”— When Progress encounters aNO-FILLtable, it doesn’t fill that table and does not continue down to any children of that table, in effect ending theFILLfor that entire branch of the ProDataSet, if there are multiple levels of Data-Relations. In the case of the present example, thettItemtable (which is referenced in the code block above as buffer-handle3in the ProDataSet) is the child ofttOline, so ordinarily it would suffice to setttOlinetoNO-FILL. But the ProDataSet definition makes the Data-Relation betweenttOlineandttItemaREPOSITIONrelation, which means that at the time of theFILL,ttItemis treated as a top-level table, so that allItemsare loaded into the ProDataSet. TheREPOSITIONrelation just tells Progress to select the currentItemfor eachOrderLineautomatically in the user interface. For this reason you have to set theFILL-MODEto “NO-FILL” forttItem, as well asttOline, to keep theItemsfrom being populated until they’re needed.- Setting the
ACTIVEattribute of one or more relations toFALSE— Or to set the ProDataSet’sRELATIONS-ACTIVEattribute toFALSE, which setsACTIVEto false for all relations. When you do aFILLon the ProDataSet handle in this case, Progress does not stop filling children when it encounters a deactivated relation. Instead, it treats every child of a deactivated relation as a top-level table and fills all such tables independently, that is, either with all records from the Data-Source or by using a query if you’ve defined one for the Data-Source. This method can, therefore, be useful when for some reason you want to define independent queries for a set of tables that are otherwise related, or that should be related after theFILL, when you are navigating the data.- Executing the
FILLmethod on a temp-table buffer handle — Do this rather than on the ProDataSet itself. In this case, Progress fills only from that table down. This can limit the extent of the fill if there is more than one top-level table in the ProDataSet. Also, when you execute aFILLstarting at a specific buffer, Progress does not treat children of deactivated relations under that buffer as top-level tables. Instead, it simply ends the fill at the level of the parent of the deactivated relation.This different behavior for a
FILLon a buffer is there specifically to provide you with enough alternatives to satisfy just about any requirement. There is almost always more than one way to get the level ofFILLthat you want. Don’t be unduly confused by all the alternatives. Just pick a way that works for your situation.To show you an example of one alternative to the one the example uses, the code in
fetchOrderscould deactivate the first relation in the ProDataSet, betweenttOrderandttOline. In this case, you would have to do theFILLon thettOrderbuffer rather than on the ProDataSet. Otherwise, thettOrderandttItemtables would be filled with all theOrderLinesandItemsin the database, which is not what you want. So the code would look like this:
Note, again, that in this case you do the
FILLon the first buffer handle, not on the ProDataSet. Also, you have to remember to set theACTIVEattribute back toTRUEwhen you need to fill the detail later on.Another point to remember in this case is that any event procedures defined at the level of the ProDataSet will not fire when you do a
FILLon thettOrdertable. In our example, the support procedure prepares theOrderquery in theBEFORE-FILLevent for the ProDataSet and detaches the Data-Sources in theAFTER-EVENTfor the ProDataSet, so this code would need to be moved to theFILLevents for theOrdertable. These are all things to consider when you are designing the structure of your procedures and event handlers.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |